package lambda.string;

import java.util.Arrays;

public class SplitDemo {
    public static void main(String[] args) {
        String str = "abc123def456ghi";
        String[] arr = str.split("[0-9]+");
        System.out.println(Arrays.toString(arr));
        //如果连续遇到可拆分项时,它们之间会拆分出一个空字符串
        str = "abc==def=ghi";
        arr = str.split("=");
        System.out.println(Arrays.toString(arr));
        //如果一上来就是可拆分项,那么拆分出的第一项为一个空字符串
        str = "=abc=def=ghi";
        arr = str.split("=");
        System.out.println(Arrays.toString(arr));
        //如果是默认连续出现可拆分项,那么所有拆分出的空字符串都会被忽略掉
        str = "abc=def=ghi=======";
        arr = str.split("=");
        System.out.println(Arrays.toString(arr));

        //将图片重命名
        String name = "123.jpg";
        String[] names = name.split("\\.");
        System.out.println(Arrays.toString(names));
        long ms = System.currentTimeMillis();
        name = ms + "." + names[1];
        System.out.println(name);


    }
}
